<!--内部机构维护画面-->
<template>
  <div class="app-container">
    <ht-search-form
      v-show="showSearch"
      :dictMap="dictMap"
      :labelWidth=100
      :queryParams="queryParams"
      :outputQueryParams="queryParams"
      :formOptions="formOptions"
      :advOptions="[]"
      :defaultEventKey="defaultEventKey"
    ></ht-search-form>
    <ht-table
      ref="dataTable"
      rowKey="sysType,bankCode,brno"
      :showSerialNumber="false"
      :multi-select="false"
      :dictMap="dictMap"
      :reqConfig="reqConfig"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
      :opButtonList="opButtonList"
    >
      <template v-slot:operate>
        <el-table-column
          label="操作"
          align="left"
          width="200px"
          fixed="right"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                 {
                  label: '修改',
                  doFunc: () => {
                    edit(scope.row);
                  },
                },
                {
                  label: '删除',
                  doFunc: () => {
                    del(scope.row);
                  },
                },
                {
                  label: '明细',
                  doFunc: () => {
                    detail(scope.row);
                  },
                },

              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>
    <brno-add-dialog
      ref="brnoAddDialog"
    ></brno-add-dialog>

    <brno-detail-dialog
      ref="brnoDetailDialog"
    ></brno-detail-dialog>

    <brno-edit-dialog
      ref="brnoEditDialog"
      @editComplete="editComplete"
    ></brno-edit-dialog>
  </div>
</template>
<script>
import { apiUrlConfig,brnoDelete } from "@/api/cnaps/bizMng/brnoBind.js";
import BrnoAddDialog from "./add";
import BrnoDetailDialog from "./detail";
import BrnoEditDialog from "./edit";
import { listPageMixin } from "@/libs/listPageMixin";

export default {
  name: "brnoBind_index",
  mixins: [listPageMixin],
  components: {
    BrnoAddDialog,
    BrnoDetailDialog,
    BrnoEditDialog,
  },
  props: {
  },
  data() {
    return {
      reqConfig: apiUrlConfig,
      total: 0,
      dataList: [],
      defaultEventKey: "",
      //数据字典
      searchFormDictList: [
        "ORGAN_SYSTYPE_BRANCH",
      ],
      // 遮罩层
      loading: true,
      // 弹出层标题
      title: "",
      showSearch: true,
      // 日期范围
      dateRange: [],
      // 查询参数
      queryParams: {
        sysType:'',
        bankCode:'',
        brno:'',
      },
      formOptions: [],
      opButtonList: () => {
        return [
        {
            label: "新增",
            type: "primary",
            icon: "el-icon-plus",
            actionType: 'add',
            clickFun: () => {
              this.add();
            }
          },
        ];
      },
      tableBindColumns: [
        { label: `内部机构号`, prop: "brno", align: "center", width: "200px" },
        { label: `参与行行号`, prop: "bankCode", align: "center", width: "200px" },
        { label: `参与行行名`, prop: "orgFullName", align: "center", width: "200px" },
        { label: `渠道`, prop: "sysType", align: "center", width: "200px",dictCode: "ORGAN_SYSTYPE_BRANCH" },
        { label: `渠道系统日期`, prop: "curSysDate", align: "center", type: "date"},

      ],
    };
  },
  mounted() {
    // this.getList()
    this.formOptions = [
      {
        type: "dict",
        dict: "ORGAN_SYSTYPE_BRANCH",
        prop: "sysType",
        defaultAttr: {
          label: "渠道",
          placeholder: "请选择渠道",
        },
      },
      {
        type: "input",
        prop: "bankCode",
        defaultAttr: {
          label: "参与行行号",
          placeholder: "请输入参与行行号",
        },
      },
      {
        type: "input",
        prop: "brno",
        defaultAttr: {
          label: "内部机构号",
          placeholder: "请输入内部机构号",
        },
      },
    ];
  },
  methods: {
    editComplete(state) {
      if (state == true) {
        this.getList();
      }
    },
    /** todo 查询当天操作员的交易记录 */
    getList() {
      this.doQuery();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    add() {
      console.log("this.$refs.brnoAddDialog", this.$refs.brnoAddDialog);
      this.$refs.brnoAddDialog.show(this.row);
    },
    edit(row) {
      console.log("this.$refs.brnoEditDialog", this.$refs.brnoEditDialog);
      this.$refs.brnoEditDialog.show(row);
    },
    detail(row) {
      console.log("this.$refs.brnoDetailDialog", this.$refs.brnoDetailDialog);
      this.$refs.brnoDetailDialog.show(row);
    },
    del(row) {
      this.$confirm("确认删除该条内部机构维护信息?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(function() {
          return brnoDelete(row);
        })
        .then(res => {
          if (res.code === 'S') {
            this.msgSuccess("删除提交成功");
            this.$alert(`CORE_ID: ${res.result.rspId}`, "生成交易流水号", {
              confirmButtonText: "确定",
              //刷新一下查询列表
              callback: (action) => {
              },
            });
            this.handleQuery();
          }
        })
        .catch(action => {});
    },
  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}
</style>
